//
//  YZIMAssitantWelcomeCell.m
//  VET
//
//  Created by YZ on 2018/7/11.
//  Copyright © 2018年 YZ. All rights reserved.
//

#import "YZIMAssitantWelcomeCell.h"

@interface YZIMAssitantWelcomeCell()

@property (nonatomic, strong) UIImageView *containerImgView;

@property (nonatomic, strong) UILabel *dateLb;

@property (nonatomic, strong) UILabel *titleLb;

@property (nonatomic, strong) UILabel *contentLb;

@property (nonatomic, strong) UILabel *signatureLb;

@end

@implementation YZIMAssitantWelcomeCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        self.layer.masksToBounds = YES;
        self.backgroundColor = [UIColor clearColor];
        [self.contentView addSubview:self.dateLb];
        [self.contentView addSubview:self.containerImgView];
        [self.containerImgView addSubview:self.titleLb];
        [self.containerImgView addSubview:self.contentLb];
        [self.containerImgView addSubview:self.signatureLb];
        
        [self makeContraints];
    }
    return self;
}

- (void)makeContraints
{
    [self.dateLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.contentView);
        make.top.mas_equalTo(0);
        make.width.mas_lessThanOrEqualTo(200);
    }];
    
    [self.containerImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.dateLb.mas_bottom).offset(kCurrentDeviceNum(15));
        make.left.mas_equalTo(kCurrentDeviceNum(10));
        make.right.mas_equalTo(self.contentView.mas_right).offset(-kCurrentDeviceNum(10));
        make.bottom.equalTo(self.contentView.mas_bottom).offset(-kCurrentDeviceNum(20));
    }];
    
    [self.titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(kCurrentDeviceNum(20));
        make.top.mas_equalTo(kCurrentDeviceNum(20));
        make.width.mas_lessThanOrEqualTo(kCurrentDeviceNum(200));
    }];
    
    [self.contentLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.titleLb);
        make.right.mas_equalTo(self.containerImgView.mas_right).offset(-kCurrentDeviceNum(20));
        make.top.equalTo(self.titleLb.mas_bottom).offset(kCurrentDeviceNum(5));
        make.height.mas_lessThanOrEqualTo(kCurrentDeviceNum(102));
    }];
    
    [self.signatureLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentLb);
        make.top.equalTo(self.contentLb.mas_bottom).offset(kCurrentDeviceNum(5));
        make.bottom.equalTo(self.containerImgView.mas_bottom).offset(-kCurrentDeviceNum(10));
    }];
}

#pragma mark -- setters && getters

- (UIImageView *)containerImgView
{
    if(!_containerImgView){
        _containerImgView = [UIImageView new];
        _containerImgView.image = [UIImage imageNamed:@""];
    }
    return _containerImgView;
}

- (UILabel *)dateLb
{
    if(!_dateLb){
        _dateLb = [UILabel new];
        _dateLb.textColor = kColorWithHex(0x9B9B9B);
        _dateLb.font = kCurrentDeviceFont(12);
        _dateLb.textAlignment = NSTextAlignmentCenter;
    }
    return _dateLb;
}

- (UILabel *)titleLb
{
    if(!_titleLb){
        _titleLb = [UILabel new];
        _titleLb.textColor = kColorWithHex(0x434343);
        _titleLb.font = kCurrentDeviceBoldFont(18);
        _titleLb.textAlignment = NSTextAlignmentLeft;
    }
    return _titleLb;
}

- (UILabel *)contentLb
{
    if(!_contentLb){
        _contentLb = [UILabel new];
        _contentLb.textColor = kColorWithHex(0x434343);
        _contentLb.font = kCurrentDeviceFont(16);
        _contentLb.textAlignment = NSTextAlignmentLeft;
        _contentLb.numberOfLines = 0;
    }
    return _contentLb;
}

- (UILabel *)signatureLb
{
    if(!_signatureLb){
        _signatureLb = [UILabel new];
        _signatureLb.textColor = kColorWithHex(0x434343);
        _signatureLb.font = kCurrentDeviceFont(16);
        _signatureLb.textAlignment = NSTextAlignmentRight;
    }
    return _signatureLb;
}

- (void)setModel:(YZIMAssitantWelcomeModel *)model
{
    _model = model;
    self.dateLb.text = model.date;
    self.titleLb.text = model.title;
    self.contentLb.text = model.content;
    self.signatureLb.text = model.signture;
}
@end
